package com.ziven.common.widget.value;

import android.graphics.drawable.Drawable;
import android.view.View;

import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;

import com.ziven.easygo.util.ViewHelper;

/**
 * @author Ziven
 */
public class Navigation extends Value {

    public static Navigation drawableId(@DrawableRes int drawableId) {
        return new Navigation().accept(my -> my.resId = drawableId);
    }

    public static Navigation drawable(Drawable drawable) {
        return new Navigation().accept(my -> my.value = drawable);
    }

    private Navigation() {}

    @Override
    protected void takeEffect(@NonNull ViewHelper<? extends View> helper) {
        if(resId == 0) {
            value(Drawable.class, helper::setNavigationIcon);
        } else {
            helper.setNavigationIcon(resId);
        }
    }
}
